﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CodeKicker.BBCode;

namespace VSDoc2JsDoc
{
    class BBCodeFilter
    {
        private BBCodeParser bbcodeParser;

        public BBCodeFilter()
        {
            var tags = new[] 
            { 
               new BBTag("b", "<strong class=\"bbcode-bold\">", "</strong>"),
               new BBTag("i", "<em class=\"bbcode-italic\">", "</em>"),
               new BBTag("u", "<em class=\"bbcode-underline\">", "</em>"),
               new BBTag("s", "<del class=\"bbcode-strikethrough\">", "</del>"),
               new BBTag("code", "<code class=\"bbcode-code\">", "</code>"),
               new BBTag("img", "<img src=\"${content}\" class=\"bbcode-image\" />", "", false, true),
               new BBTag("quote", "<blockquote class=\"bbcode-quote\">", "</blockquote>"),
               new BBTag("sup", "<sup class=\"bbcode-superscript\">", "</sup>"),
               new BBTag("sub", "<sub class=\"bbcode-subscript\">", "</sub>"),
               new BBTag("url", "<a href=\"${href}\" class=\"bbcode-url\">", "</a>", new BBAttribute("href", ""), new BBAttribute("href", "href"))
            };

            this.bbcodeParser = new BBCodeParser(ErrorMode.ErrorFree, null, tags);
        }

        public string ToHtml(string bbcode)
        {
            return bbcodeParser.ToHtml(bbcode);
        }
    }
}
